package global

import "github.com/kataras/iris/v12"

func WriteError(ctx iris.Context, code int, err error) {
	result := iris.Map{
		"code":    code,
		"data":    nil,
		"message": err.Error(),
	}
	_ = ctx.JSON(result)
}

func WriteData(ctx iris.Context, data interface{}) {
	result := iris.Map{
		"code":    0,
		"data":    data,
		"message": nil,
	}
	_ = ctx.JSON(result)
}
